package com.springcloud.consumer.Controller;

import com.springcloud.consumer.Remote.HelloRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * @program: SpringBootCloud
 * @description: web层调用远程服务
 * @author: 肖垚 1094890313@qq.com
 * @create: 2019年01月18日 09:46
 **/
@RefreshScope
@RestController
//@RequestMapping(value = "/s_user", produces = "text/plain;charset=UTF-8")
//@RequestMapping(produces = "text/plain;charset=UTF-8")
public class ConsumerController {

//    @Qualifier("helloRemoteHystrix")
    @Autowired
    HelloRemote helloRemote;
//    HelloRemoteHystrix helloRemote;

    @RequestMapping(value = "/hello/{name}", method = RequestMethod.GET)
    public String index(@PathVariable("name") String name) {
        return helloRemote.hello(name);
    }

    @RequestMapping(value = "/hello2/{name}", method = RequestMethod.GET)
    public String index2(@PathVariable("name") String name) {
        return helloRemote.hello2(name);
    }


    @Value("${name}")
    private String name;

    @RequestMapping("/name")
    public String from() {
        return this.name;
    }
}